package com.ghsc.ghxc.jsb.ui.message.activity

import androidx.lifecycle.MutableLiveData
import com.cn.appcore.base.BaseViewModel
import com.cn.appcore.ext.executeResponse
import com.cn.appcore.http.bean.BaseResponse
import com.ghsc.ghxc.jsb.api.ApiMarket
import com.ghsc.ghxc.jsb.ui.live.bean.ReceiveResult
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

/**
 * 项目：GuoHuaMall
 * 包名：com.ghsc.ghxc.ui.message.activity
 * 类名：RedExtensionViewModel
 * 创建时间：2023/8/3 12:07
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 */
class RedExtensionViewModel  : BaseViewModel() {


//
    /** 获取发红包所需参数 **/
    var onRedIndexData = MutableLiveData<BaseResponse<ReceiveResult>>()
    fun onRedIndexDataMethod(paras:String) {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.onSendGroupPacketInfoData(paras) }
            executeResponse(
                response,
                { onRedIndexData.value = response},
                { againLoginMsg.value = response.msg}
            ) { errorMsg.value = response.msg }

        }
    }
//
//
    /** 发送红包  **/
    val onSendPacketSubmitData: MutableLiveData<BaseResponse<Any>> = MutableLiveData()
    fun onSendPacketSubmitMethod(paras:String) {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.onLiveSendPacketSubmitData(paras) }
            executeResponse(
                response,
                { onSendPacketSubmitData.value = response},
                { againLoginMsg.value = response.msg}
            ) { errorMsg.value = response.msg }

        }
    }
//    /** 发送红包 单人 **/
//    val onSendSingleRedData: MutableLiveData<BaseResponse<SendSingleRedResult>> = MutableLiveData()
//    fun onSendSingleRedMethod(paras:String) {
//        launch {
//            val response = withContext(Dispatchers.IO) { mainRepository.onSendSingleRedData(paras) }
//            executeResponse(
//                response,
//                { onSendSingleRedData.value = response},
//                { againLoginMsg.value = response.msg}
//            ) { errorMsg.value = response.msg }
//
//        }
//    }
//
//
//    /**  支付宝 获取id_verify  **/
//    val onAlipayIdData: MutableLiveData<BaseResponse<AlipayIdResult>> = MutableLiveData()
//    fun onAlipayIdMethod(paras: String) {
//        launch {
//            val response = withContext(Dispatchers.IO) { mainRepository.onAlipayIdData(paras) }
//            executeResponse(
//                response,
//                { onAlipayIdData.value = response},
//                { againLoginMsg.value = response.msg}
//            ) { errorMsg.value = response.msg }
//
//        }
//    }
//    /**
//     * 个人中心
//     */
//    val onUserInfoData: MutableLiveData<BaseResponse<UserResultDataBean>> = MutableLiveData()
//    fun onUserInfoMethod(paras:String) {
//        launch( {
//            val response = withContext(Dispatchers.IO) { mainRepository.onUserInfoData(paras) }
//            executeResponse(
//                response,
//                { onUserInfoData.value = response},
//                { againLoginMsg.value = response.msg}
//            ) { errorMsg.value = response.msg }
//            catchResponse { mException.value }
//        },
//            {
//                catchResponse { mException.value =it }
//            }
//        )
//
//    }

}
